#!/usr/bin/env python

# -------------------------------
# projects/python/collatz/main.py
# Copyright (C) 2009
# Glenn P. Downing
# -------------------------------

# To run the program
#     main.py < Collatz.in > Collatz.out

# To document the program
#     pydoc -w main

# -------
# globals
# -------

i = 0 # input: don't change after reading
j = 0 # input: don't change after reading
v = 0 # output

#First approach to cache, cache cycle length of number once found..using dictionary
#Didn't want to use dictionary but the speed increase is significant, 1 1000000 30 seconds without, 1.9 with
cache = {}


# -----------
# InputReader
# -----------

class InputReader (object) :
    def read (self) :
        return raw_input()

# ------------
# OutputWriter
# ------------

class OutputWriter (object) :
    def write (self, *a) :
        for w in a :
            print w,
        print

# -------
# my_read
# -------

def my_read (r) :
    """
    reads an int into i and j
    return true if that succeeds, false otherwise
    """
    global i
    global j
    try :
        s = r.read()
    except EOFError :
        return False
    l = s.split()
    i = int(l[0])
    j = int(l[1])
    return True

# -------
# my_eval
# -------

def my_eval () :
    """
    computes the max cycle length in the range [i, j]
    and stores the result in v
    """
    global v, i, j
    i2 = i
    j2 = j
    if(i2 > j2):
        i2 = i2^j2
        j2 = i2^j2
        i2 = i2^j2
    v = 0
    for k in range(i2, j2 + 1):
        cycleLen = calcCycleLen(k)
        if (cycleLen > v):
            v = cycleLen

 
def calcCycleLen(num) :
    """
    computes the cycle length for value num
    checks if the length is already stored in
    cache, if not then stores the cycle length
    """
    if(num == 1):
        return 1
    if num in cache:
        return cache[num]
    if((num % 2) == 0):
        val = 1 + calcCycleLen(num >> 1)
        cache[num] = val 
        return val
    val = 2 + calcCycleLen(num + (num >> 1) + 1)
    cache[num] = val
    return val

# --------
# my_print
# --------

def my_print (w) :
    """
    writes the values of i, j, and v
    """
    w.write(i, j, v)

# ----
# main
# ----

def main () :
    """
    runs the program
    """
    while my_read(InputReader()) :
        my_eval()
        my_print(OutputWriter())

if __name__ == "__main__" :
    main()
